<template>
  <div>
    <page-tab-list
      url="/ChsDangerNotPorduce/GetPageData"
      :params="params"
      @initActive="_initActive"
      @initList="_initList"
      ref="PageTabList"
    >
    <div v-if="this.active === 0">
        <van-cell
        class="card"
        @click="openDetail(item)"
        v-for="(item, index) in list"
        :key="index"
      >
        <div>
          <div>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_enterprise.png"
                />公司：{{ item.EnterpriseName }}
              </van-col>
            </van-row>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_view.png"
                />状态：{{ item.StatusName }}
              </van-col>
            </van-row>
           
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_user.png"
                />整改部门：{{ item.CorrectiveDeptName }}
              </van-col>
            </van-row>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_date.png"
                />录入时间：{{ item.CreateDate}}
              </van-col>
            </van-row>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_company_check.png"
                />隐患描述：{{ item.HiddenDangerDesc }}
              </van-col>
            </van-row>
            <van-row>
              <van-col span="24">
                <div class="dep_btm">
                  <div
                    class="btm_item"
                    v-if="item.Status == '20'"
                    @click.stop="openEdit(item.ID)"
                  >
                    <img
                      src="@/assets/Images/AppIcon/icon_list_edit.png"
                      alt=""
                    />
                    <div class="mr-10">整改反馈</div>
                  </div>
                  <div
                    class="btm_item"
                    @click.stop="delData(item)"
                    v-if="item.Status == '20'"
                    style="margin-right: 15px"
                  >
                    <img src="@/assets/Images/AppIcon/icon_list_distribution.png" 
                    alt="" />
                    <div>退回</div>
                  </div>
                </div>
              </van-col>
            </van-row>
          </div>
        </div>
      </van-cell>
    </div>
    <div v-if="this.active === 1">
      <van-cell
        class="card"
        @click="openDetail(item)"
        v-for="(item, index) in list"
        :key="index"
      >
        <div>
          <div>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_enterprise.png"
                />公司：{{ item.EnterpriseName }}
              </van-col>
            </van-row>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_group.png"
                />状态：{{ item.StatusName }}
              </van-col>
            </van-row>
           
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_user.png"
                />整改部门：{{ item.CorrectiveDeptName }}
              </van-col>
            </van-row>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_date.png"
                />录入时间：{{ item.CreateDate}}
              </van-col>
            </van-row>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_company_check.png"
                />反馈内容：{{ item.CorrectiveDesc }}
              </van-col>
            </van-row>
          </div>
        </div>
      </van-cell>
    </div>
    </page-tab-list>
  </div>
</template>
<script>
import { getMenuByMenuCode } from "@/api/common";
import {getPageData} from "@/api/NonSafetyProduction";
import PageTabList from "@/components/PageTabList/PageTabList.vue";
export default {

  components: { PageTabList },

   data() {

    return {
      rightValue: 0,
      active: 0, 
      list: [],
      params: [
        {
          title: "未反馈",
          dataType: "string",
           type: "correctiveList_yts"
        },
        {
          title: "已反馈",
          dataType: "string",
           type: "correctiveList_yfk"
        },
      ],     
    };
    
  },

  created() {
    this.getMenuByMenuCode();
  },
  methods: {
    _initActive(active) {
      this.active = active;
    },
    _initList(list) {
      this.list = list;
    },    
    openDetail(item) {
      this.$router.push({
        path: "/RCfeedback/Detail",
        query: { id: item.ID },
      });
    },

    openEdit(id) {
      // GET /api/ChsDangerNotPorduce/Edit/{id}
      this.$router.push({
        path: "/RCfeedback/Edit",
        query: { id: id },
      });
      return true;
      
    },

    delData(item) {
      this.$dialog
        .confirm({
          title: "询问",
          message: "您确定要退回该条记录吗？",
        })
        .then(() => {
          let params = { id: item.ID };
          this.$axios
          // GET /api/ChsDangerNotPorduce/ExitCorrective/{id} 
            .get('/ChsDangerNotPorduce/ExitCorrective/{id}', {
              params: params,
            })
            .then((res) => {
              this.$toast("退回成功");
              // this.$router.go(0);
              this.$refs.PageTabList.refreshList();
            });
        })
    },
  
    getMenuByMenuCode() {
        var me = this;
        getMenuByMenuCode("GxInterviewRecord_List").then((res) => {
          me.rightValue = res.data ? res.data.RoleRightValue : 0;
        });
      },
  }
}
</script>
<style lang="less" scoped>
.dep_btm {
  display: flex;
  justify-content: flex-end;
  line-height: 27px;
  .btm_item {
    display: flex;
    align-items: center;
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}
</style>
